package com.edu.service.impl;

import com.as.util.DBUtil;
import com.edu.dao.UserDao;
import com.edu.dao.impl.UserDaoImpl;
import com.edu.domain.User;
import com.edu.service.UserService;

/**
 *  用户业务层接口实现类
 * 描述：
 * 创建人：飘
 * 创建时间：2024/10/31
 **/
public class UserServiceImpl implements UserService {
    private UserDao userDao=new UserDaoImpl();
    @Override
    public int saveUser(User user) {
        int result=0;
        try {
            result=this.userDao.saveUser(user);
        } catch (Exception e) {
            result=1;
            e.printStackTrace();
        }
        finally {
            DBUtil.close();
        }
        return result;
    }

    @Override
    public User getUserByIdByPass(User user) {
        User user1=null;
        try {
            user1=this.userDao.getUserByIdByPass(user);
        } catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            DBUtil.close();
        }
        return user1;
    }

    @Override
    public User getUserById(String userId) {
        User user=null;
        try {
            user=this.userDao.getUserById(userId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            DBUtil.close();
        }

        return user;
    }
}
